package com.zy.controller;

import com.zy.Vo.OutboundVo;
import com.zy.Vo.ResultVo;
import com.zy.pojo.Outbound;
import com.zy.service.OutboundService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
@RequestMapping("/outbound")
public class OutboundController {
    @Resource
    private OutboundService outboundService;

    @GetMapping("/pagelist/{pageNo}/{pageSize}")
    public ResultVo getOutboundPageList(@PathVariable Integer pageNo, @PathVariable Integer pageSize, OutboundVo outboundVo){
        return ResultVo.sucess(outboundService.getPageOutboundList(pageNo,pageSize,outboundVo));
    }

    @PostMapping("/outboundadd")
    public ResultVo getOutboundAdd(@RequestBody Outbound outbound, HttpSession httpSession){
        try{
            outbound.setOutboundDate(new Date());
            outboundService.getOutboundAdd(outbound);
            return ResultVo.sucess("添加出库商品成功");
        }catch (Exception e){
            return ResultVo.fail("添加出库商品失败",e);
        }
    }
    @GetMapping("/outbounddel/{id}")
    public ResultVo getOutboundDelete(@PathVariable String id){
        try{
            outboundService.getOutboundDelete(Integer.parseInt(id));
            return ResultVo.sucess("删除出库商品成功");
        }catch (Exception e){
            return ResultVo.fail("删除出库商品失败",e);
        }
    }
    }
